package com.hsylient.javase.chapter11.future;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

@Slf4j
public class FutureTest {


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        Future<String> submit = executorService.submit(() -> {
            TimeUnit.SECONDS.sleep(3);
            return "执行任务后返回的结果";
        });

        // 这里会卡住主线程的执行
        log.info(submit.get());

        executorService.shutdown();
    }
}
